package com.yh.zz_hlj.modules.adatper;

/**
 * Created by kangdong on 2015/10/31.
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yh.zz_hlj.R;


public class SearchLeftAdapter extends BaseAdapter {
	private Context context;
	private String[] strings;
	private int  selectItem=0;
	public SearchLeftAdapter(Context context, String[] strings ) {
		this.context = context;
		this.strings = strings;
	}

	@Override
	public int getCount() {
		if (strings == null) {
			return 0;
		}
		return strings.length;
	}

	@Override
	public Object getItem(int position) {
		if (strings == null) {
			return null;
		}
		return strings[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.dialog_search_shaixuan_left_item, parent, false);
			holder.tv_left_name = (TextView) convertView
					.findViewById(R.id.tv_left_name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
        if(this.selectItem==position){
			holder.tv_left_name.setTextColor(this.context.getResources().getColor(R.color.darker_blue));
		}else{
			holder.tv_left_name.setTextColor(this.context.getResources().getColor(R.color.gray));
		}
		holder.tv_left_name.setText(strings[position]);
		return convertView;
	}

	public  void setSelectItem(int selectItem) {
		this.selectItem = selectItem;
	}

	public static class ViewHolder {
		public TextView tv_left_name;
	}

}
